package club.attachie.base;

import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.DisplayName;

import java.math.BigInteger;

public class BigIntegerDemoTest {
    @Test
    @DisplayName("测试")
    public void test() {
        BigInteger big1 = new BigInteger("12");
        BigInteger big2 = BigInteger.valueOf(12L);
        Assert.assertEquals(big1, big2);
        Assert.assertTrue(big2.equals(big1));
        boolean isSame = big2 == big1;
        Assert.assertTrue(!isSame);
    }

    @Test
    @DisplayName("测试valueOf")
    public void  testValueOf(){
        BigInteger big1 = BigInteger.valueOf(15);
        BigInteger big2 = BigInteger.valueOf(15);
        // <16时，只创建一个示例
        Assert.assertEquals(big1, big2);
        Assert.assertTrue(big2 == big1);
    }
}
